﻿using HandyControl.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MonitorModule.Views {
    /// <summary>
    /// Settings.xaml 的交互逻辑
    /// </summary>
    public partial class Settings : UserControl {
        public Settings() {
            InitializeComponent();
        }

        private void RadioButton_Click(object sender, RoutedEventArgs e) {
            if (sender is RadioButton radioBtn && radioBtn.Tag != null) {
                string targetName = radioBtn.Tag.ToString();
                var targetControl = FindName(targetName) as FrameworkElement;

                if (targetControl != null) {
                    // 获取目标控件在ScrollViewer中的位置
                    Point relativePosition = targetControl.TransformToVisual(scrollViewer.Content as Visual)
                                              .Transform(new Point(0, 0));

                    // 滚动到目标位置（带平滑动画）
                    scrollViewer.ScrollToVerticalOffset(relativePosition.Y);
                }
            }
        }
    }
}
